import ProxyInterface from '../proxy-interface';
import {
  CollectionModel, CollectionPageModel, FileModel, SubscriptionModel,
  SubscriptionPageModel
} from '../model/file';

class FileProxy implements ProxyInterface<FileModel> {
  private file = new FileModel();

  constructor (responseData) {
    let data = responseData.data || responseData;
    Object.assign<FileModel, any>(this.file, data);
  }

  getModel (): FileModel {
    return this.file;
  }
}

class SubscriptionProxy implements ProxyInterface<SubscriptionModel> {
  private subscription = new SubscriptionModel;

  constructor (responseData) {
    let data = responseData.data || responseData;
    Object.assign<SubscriptionModel, any>(this.subscription, data);
  }

  getModel (): SubscriptionModel {
    return this.subscription;
  }
}

class SubscriptionPageProxy implements ProxyInterface<SubscriptionPageModel> {
  private subscriptionPage = new SubscriptionPageModel;

  constructor (responseData) {
    let data = responseData;
    Object.assign<SubscriptionPageModel, any>(this.subscriptionPage, data);
  }

  getModel (): SubscriptionPageModel {
    return this.subscriptionPage;
  }
}

class CollectionProxy implements ProxyInterface<CollectionModel> {
  private collection = new CollectionModel;

  constructor (responseData) {
    let data = responseData.data || responseData;
    Object.assign<CollectionModel, any>(this.collection, data);
  }

  getModel (): CollectionModel {
    return this.collection;
  }
}

class CollectionPageProxy implements ProxyInterface<CollectionPageModel> {
  private collectionPage = new CollectionPageModel;

  constructor (responseData) {
    let data = responseData;
    Object.assign<CollectionPageModel, any>(this.collectionPage, data);
  }

  getModel (): CollectionPageModel {
    return this.collectionPage;
  }
}

export {
  FileProxy,
  SubscriptionProxy,
  SubscriptionPageProxy,
  CollectionProxy,
  CollectionPageProxy
};
